import { isEmpty } from '../../utils/util'

const app = {
  state: {
    menuList: isEmpty(sessionStorage.getItem('menuList')) ? [] : JSON.parse(sessionStorage.getItem('menuList')),
    routerList: isEmpty(sessionStorage.getItem('routerList')) ? [] : JSON.parse(sessionStorage.getItem('routerList'))
  },
  mutations: {
    SET_MENU_LIST: (state, menu) => {
      state.menuList = menu
    },
    SET_ROUTER_LIST: (state, list) => {
      state.routerList = list
    }
  },
  actions: {
    setMenuList({ commit }, menu) {
      commit('SET_MENU_LIST', menu)
    },
    setRouterList({ commit }, list) {
      commit('SET_ROUTER_LIST', list)
    }
  }
}

export default app
